package com.gxa.meiye.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.gxa.meiye.admin.mapper.CommentMapper;
import com.gxa.meiye.admin.service.CommentService;
import com.gxa.meiye.core.common.ResponseData;
import com.gxa.meiye.core.pojo.domain.lzj.Comment;
import com.gxa.meiye.core.pojo.vo.CommentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, CommentVO> implements CommentService{

    @Autowired
    private CommentMapper commentMapper;
    @Override
    public ResponseData queryById() {
        ResponseData rd=new ResponseData();
        List<CommentVO> cs = commentMapper.queryById();
        rd.setCode(200);
        rd.setMsg("查询成功");
        rd.setData(cs);
        return rd;
    }

    @Override
    public ResponseData addCommen(String ordernumber, String phone, Comment comment) {
        ResponseData rd=new ResponseData();
        String id = commentMapper.selectID(phone);
        String s = commentMapper.selectOID(ordernumber);
        String s1 = commentMapper.selectImage(ordernumber);
        comment.setUserId(id);
        comment.setOrderId(s);
        comment.setImages(s1);
        Integer i= commentMapper.addComment(comment);
        if (i > 0) {
            rd.setCode(200);
            rd.setMsg("添加成功");
        } else {
            rd.setCode(500);
            rd.setMsg("添加失败");
        }
        return rd;
    }


}
